require "set"

name_filter :tags do |names, configurations, options|
  tags = (options[:tags] || "").split(",").map { |tag| tag.to_sym }.to_set
  names.delete_if do |name|
    #TODO: find a better place for default_area tag setting
    conf = configurations[name]
    conf_tags = conf.tags.to_set
    conf_tags << conf.default_area if conf.exists? :default_area
    !tags.subset?(conf_tags)
  end
  
end

